/**
 * 路由配置
 */

/* Layout */
import Layout from '@/layout/layoutPair'
import secondMain from '@/layout/layoutPair/SecondMain'
import { getAsyncRoutes } from './menu'
import { compile } from 'path-to-regexp'

// 静态路由
export const constantRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard' }
      },
      {
        path: '/infoEcharts',
        name: '信息统计',
        component: () => import('@/views/infoEcharts/index'),
        meta: { title: '信息统计', icon: 'dashboard' }
      },
      {
        path: '/publicSentiment',
        name: '舆情处置',
        component: () => import('@/views/publicSentiment/index'),
        meta: { title: '舆情处置', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  // 用户端登录
  {
    path: '/user-login',
    component: () => import('@/views/user-login'),
    hidden: true
  },
  // 单点登录
  {
    path: '/cas-login',
    component: () => import('@/views/cas-login'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  }
]

// 404 路由 must be placed at the end !!!
export const notFoundRouter = [{ path: '*', redirect: '/404', hidden: true }]

// 动态路由 - 接口请求
export const asyncRoutes = async function () {
  return new Promise((resolve) => {
    getAsyncRoutes().then((res) => {
      resolve(res)
    })
  })
}

// 前端文档及使用示例 路由
// export const demoRoutes = [
//   {
//     path: '/demo',
//     component: Layout,
//     redirect: '/demo/specification',
//     meta: { title: '组件&功能', icon: 'eye' },
//     children: [
//       {
//         path: 'specification',
//         name: 'Specification',
//         component: () => import('@/views/demo/Specification'),
//         meta: { title: '规范' }
//       },
//       {
//         path: 'card',
//         component: secondMain,
//         meta: { title: '卡片' },
//         redirect: '/demo/card/flex-card',
//         children: [
//           {
//             path: 'flex-card',
//             name: 'FlexCard',
//             component: () => import('@/views/demo/card/FlexCard'),
//             meta: { title: 'flex-1 卡片' }
//           },
//           {
//             path: 'auto-card',
//             name: 'AutoCard',
//             component: () => import('@/views/demo/card/AutoCard'),
//             meta: { title: 'h-auto 卡片' }
//           }
//         ]
//       },
//       {
//         path: 'icon-picker',
//         name: 'IconPicker',
//         component: () => import('@/views/demo/IconPicker'),
//         meta: { title: '图标选择' }
//       },
//       {
//         path: 'dialog',
//         name: 'Dialog',
//         component: () => import('@/views/demo/Dialog'),
//         meta: { title: '弹窗' }
//       },
//       {
//         path: 'form',
//         redirect: '/demo/form/index',
//         component: secondMain,
//         children: [
//           {
//             path: 'index',
//             name: 'Form',
//             meta: { title: 'Form 表单示例' },
//             component: () => import('@/views/demo/form')
//           }
//         ]
//       },
//       {
//         path: 'table',
//         redirect: '/demo/table/index',
//         component: secondMain,
//         children: [
//           {
//             path: 'index',
//             name: 'Table',
//             component: () => import('@/views/demo/Table'),
//             meta: { title: 'Table 表格示例' }
//           }
//         ]
//       },
//       {
//         path: 'complete',
//         redirect: '/demo/complete/index',
//         component: secondMain,
//         children: [
//           {
//             path: 'index',
//             name: 'Complete',
//             component: () => import('@/views/demo/Page/Complete'),
//             meta: { title: '完整示例' }
//           }
//         ]
//       }
//     ]
//   }
// ]
